package com.example.train.business.controller.admin;

import com.example.train.business.req.Daily_TrainTicketQueryReq;
import com.example.train.business.req.Daily_TrainTicketSaveReq;
import com.example.train.business.resp.Daily_TrainTicketQueryResp;
import com.example.train.business.service.Daily_TrainTicketService;
import com.example.train.common.resp.CommonResp;
import com.example.train.common.resp.PageResp;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/daily_TrainTicket")

public class Daily_TrainTicketAdminController {

    @Resource
    private Daily_TrainTicketService daily_TrainTicketService;

    /**
     * 乘客注册请求的controller类，用于调用service
     * 注意PostMapping必须要用requestBody注解，否则后端接受不到数据
     * @param daily_TrainTicketSaveReq
     * @return
     */
    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody Daily_TrainTicketSaveReq daily_TrainTicketSaveReq) {
        daily_TrainTicketService.save(daily_TrainTicketSaveReq);
        return new CommonResp<>();
    }
    /**
     * 查询当前会员下乘客信息列表的controller类，用于调用service
     * 注意GetMapping不用requestBody注解，否则后端接受不到数据
     * @param @VALID Daily_TrainTicketQueryReq
     * @return CommonResp<PageResp<Daily_TrainTicketQueryResp>>
     */
    @GetMapping("/query-list")
    public CommonResp<PageResp<Daily_TrainTicketQueryResp>> queryList(@Valid Daily_TrainTicketQueryReq req) {
        PageResp<Daily_TrainTicketQueryResp> list = daily_TrainTicketService.queryList(req);
        return new CommonResp<>(list);
    }

    /**
     * 删除乘客信息的controller层接口
     * @param id
     * @return CommonResp<Object>
     */
    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        daily_TrainTicketService.delete(id);
        return new CommonResp<>();
    }

}

